<?php

include '../init.php';

include DIR_CORE.'/MySQLDB.php';

// 接收表单数据
$pub_title = escapeString($_POST['pub_title']);
$pub_content = escapeString($_POST['pub_content']);

// 判断数据库的合法性
if (empty($pub_title) || empty($pub_content)) {
    jump('./publish.php', '发布失败，请填写完整信息！');
}

// 数据入库
session_start();
$pub_owner = $_SESSION['userInfo']['user_name'];
$pub_time = time();
$sql = "insert into publish values(null, '$pub_title', '$pub_content', '$pub_owner', '$pub_time', default)";
$result = my_query($sql);

// 判断是否入库成功
if ($result) {
    jump('./list_father.php', '发布成功！');
} else {
    jump('./publish.php', '发布失败，请稍后再试！');
}

?>
